package msgobj

import (
	"dev_gw/device"
	mqttclient "dev_gw/mqttClient"
	"strings"
)

func Make(topic string, m *mqttclient.MqttClient, d *device.Device) MsgInterface {
	if strings.Contains(topic, "dev/") && strings.Contains(topic, "/set") {
		return NewDevSetMsgObject(m, d)
	} else if strings.Contains(topic, "dev/") && strings.Contains(topic, "/get") {
		return NewDevGetMsgObject(m, d)
	} else if strings.Contains(topic, "app/") && strings.Contains(topic, "/get") {
		return NewAppGetMsgObject(m, d)
	} else if strings.Contains(topic, "app/") && strings.Contains(topic, "/set") {
		return NewAppSetMsgObject(m, d)
	}

	return NewEmptyMsgObject(m, d)
}
